<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
<c:set var="cp" value="<%=request.getContextPath() %>"></c:set>
<!doctype html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>my-admin1.0</title>
	<meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,ch0rome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
	<link rel="stylesheet" href="lib/layui/css/layui.css">
	<link rel="stylesheet" type="text/css" href="<c:url value='/css/webuploader.css'/>">
    <script src="lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript"  src="<c:url value='/js/jquery.min.js'/>"></script>
	<script type="text/javascript" src="<c:url value='/js/webuploader.js'/>"></script>
    <style type="text/css">
    .layui-table-cell{
height:auto !important;
}
    </style>
</head>
<body class="child-body" style="padding: 10px 15px 15px 15px">     
<div class="child-nav">
    <span class="layui-breadcrumb" style="visibility: visible;">
         <a>我的工作台</a><span lay-separator="">/</span>
         <a><cite>文章列表</cite></a>
    </span>
</div>
<hr class="layui-bg-gray">
	 <div class="layui-btn-group demoTable">
        <a class="layui-btn layui-btn-sm"  href="wz.htm"><i class="layui-icon"></i>发表文章</a>
     </div>																														
	     <table class="layui-table" lay-data="{url:'listWz.htm', page:true, id:'test'}" lay-filter="test"> 
	      <thead>
	      		<tr >
					<th lay-data="{field:'id', width:280, sort: true}">文章ID</th>
					<th lay-data="{field:'title', width:450}">标题</th>
					<th lay-data="{field:'addtime', width:250}">发表时间</th>
					<th lay-data="{toolbar: '#barDemo' }">操作</th>
				</tr>
	      </thead>         
        </table>
<script type="text/html" id="barDemo">
 	<a class="layui-btn layui-btn-sm" lay-event="edit">查看</a>
 	 <a class="layui-btn layui-btn-sm layui-btn-danger" lay-event="del">删除</a>
	</script>
	<script type="text/html" id="titleTpl">
  {{#  if(d.type==1){ }}
			<video width="100" height="100" controls >
        	<source src="${cp}/upload/{{d.path}}" type="video/mp4">
        	<object data="${cp}/upload/{{d.path}}" width="100" height="100">
            <embed width="100" height="100" src="movie.swf">
        	</object></video>
  {{#  } else { }}

  {{#  } }}
	</script>
<script>
var table;
layui.use('table', function(){
	   table = layui.table;	
	   
	   //监听行工具事件
     table.on('tool(test)', function(obj){
      var data = obj.data;
      var event = obj.event;
      if(event==='edit'){
    	  window.location.href="${cp}/wzDetail.htm?id="+data.id;
      }else if(event==='del'){
    	  parent.layer.confirm('确认删除该文章吗？', function(index){
    	  $.ajax({
    			type: 'POST',
    			async:false,
    			url:"${cp}/delete.htm",
    			data:{"id":data.id},
    			success:function (data){	
    				if(data=="success"){
    					 parent.layer.close(index);
    					 table.reload('test'); 
    				}else{
    					layer.msg("删除失败！")
    				}
    			}
    	    });    	 
        });
     }
    });
});
</script>
</body>
</html>